package combat;

import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;

import actives.ActiveManager;
import actives.ActiveType;

import skills.Skill;
import skills.SkillHandler;
import skills.Skills;

public class Toughness extends Skill {

	public Toughness(Player player, int level, int exp) {
		super(player, level, exp);
	}
	
	@Override
	public void info() {
		super.info();
		message(0, "Active: Your punch disorents the next target for a shot time."); //implemented?
	    message(0, "Passive: Increase fist damage done by " + level/5 + "%");
		message(250, "Level 250 Passive: Halves damage taken form enviormental effects");
		message(750, "Level 750 Passive: Damage taken increases resistance for a short time");
	}
	
	public static void combat(EntityDamageByEntityEvent event) {
		Player damager = (Player) event.getDamager();
		ActiveManager.activate(damager, ActiveType.TOUGHNESS, event.getEntity());
		Skill toughness = SkillHandler.getSkill(damager, Skills.TOUGHNESS);
		double damage = event.getDamage();
		damage = damage * (1 + toughness.level() / 500.0);
		event.setDamage(damage);
		toughness.addExp((int) event.getDamage());
	}

	public static void toughness(EntityDamageEvent event) {
		Player player = (Player) event.getEntity();
		Skill toughness = SkillHandler.getSkill(player, Skills.TOUGHNESS);
		if (toughness.level() >= 750) {
			Resistance2.buff(player);
		}
		switch (event.getCause()) {
		case DROWNING:
		case STARVATION:
		case SUFFOCATION:
			if (toughness.level() >= 250) {
				event.setDamage(event.getDamage() / 2);
			}
			break;
		default:
			break;
		}
		toughness.addExp((int) event.getDamage());
	}
}
